<!DOCTYPE html>
<html>
<head>
    <title>Built-in Layouts</title>
    <meta charset="utf-8">
    <link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
    <link href="../../styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
    <link href="../../styles/kendo.default.min.css" rel="stylesheet">
    <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet">
    <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet">
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/kendo.all.min.js"></script>
    <script src="../content/shared/js/console.js"></script>
    <script>
        
    </script>
    
    
</head>
<body>
    
        <a class="offline-button" href="../index.html">Back</a>
    
    <div id="example">
    
    <div class="box">
        <div class="box-col">
            <h4>Layout: </h4>
               <select id="subtype">
                    <option value="down">Tree Down</option>
                    <option value="up">Tree Up</option>
                    <option value="tipover">Tipover Tree</option>
               </select>
        </div>
    </div>
    
    <div id="diagram"></div>
    <script>
        function createDiagram() {
            $("#diagram").kendoDiagram({
                dataSource: {
                    data: diagramNodes(),
                    schema: {
                        model: {
                            children: "items"
                        }
                    }
                },
                layout: {
                    type: "tree",
                    subtype: "down",
                    horizontalSeparation: 30,
                    verticalSeparation: 20
                },
                shapeDefaults: {
                    width: 40,
                    height: 40
                }
            });
        }

        function diagramNodes() {
            var root = { name: "0", items: [] };
            addNodes(root, [3, 2, 2]);
            return [root];
        }

        function addNodes(root, levels) {
            if (levels.length > 0) {
                for (var i = 0; i < levels[0]; i++) {
                    var node = { name: "0", items: [] };
                    root.items.push(node);

                    addNodes(node, levels.slice(1));
                }
            }
        }

        $(document).ready(function() {
            $("#subtype").change(function() {
                $("#diagram").getKendoDiagram().layout({
                    subtype: $(this).val(),
                    type: "tree",
                    horizontalSeparation: 30,
                    verticalSeparation: 20
                });
            });
        });

        $(document).ready(createDiagram);
        $(document).bind("kendo:skinChange", createDiagram);
    </script>
</div>


    
    
</body>
</html>
